Package cells.datahandling

Source Code of cells.datahandling.ImportDataToWorksheets

package cells.datahandling;

import java.util.ArrayList;

import com.aspose.cells.Cells;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class ImportDataToWorksheets
{
  public static void main(String[] args) throws Exception
  {
    //Instantiating a Workbook object
    Workbook workbook = new Workbook();
   
    //Obtaining the reference of the newly added worksheet by passing its sheet index
    int sheetIndex = workbook.getWorksheets().add();
    Worksheet worksheet= workbook.getWorksheets().get(sheetIndex);
   
    //==================================================
    //Creating an array containing names as string values
    String[] names = new String[]{"laurence chen", "roman korchagin", "kyle huang"};
   
    //Importing the array of names to 1st row and first column vertically
    Cells cells = worksheet.getCells();
    cells.importArray(names,0,0,false);
   
    //==================================================
    ArrayList<String> list = new ArrayList<String>();
   
    //Add few names to the list as string values
    list.add("laurence chen");
    list.add("roman korchagin");
    list.add("kyle huang");
   
    //Importing the contents of ArrayList to 1st row and first column vertically
    cells.importArrayList(list,2,0,true);
    //==================================================
   
    //Saving the Excel file
    workbook.save("data/AsposeDataImport.xls");
  }
}
TOP

Related Classes of cells.datahandling.ImportDataToWorksheets

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.